package com.boc.langxiang.presenter.shop;

import com.boc.langxiang.contract.shop.OrderBillingContract;
import com.boc.langxiang.entity.request.OrderBillingRequest;
import com.boc.langxiang.entity.response.OrderBillingResponse;
import com.boc.langxiang.net.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Li Guoxi on 2016/7/4.
 */
public class OrderBillingPresenter extends SuperPresenter implements OrderBillingContract.Presenter {
    private OrderBillingContract.View mView;

    public OrderBillingPresenter(OrderBillingContract.View mView) {
        super(mView);
        this.mView = mView;
    }



    @Override
    public void getList(String ids) {
        mView.showLoading();
        OrderBillingRequest request = new OrderBillingRequest();
        request.setIds(ids);
        mService.orderBilling(request.params())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<OrderBillingResponse>(mView) {
                    @Override
                    public void onSuccess(OrderBillingResponse response) {
                        mView.hideLoading();
                        mView.onSuccess(response);
                    }
                });
    }
}
